from flask import Flask
from App.settings import envs
from App.views import init_view

from App.ext import init_ext


def create_app(env):
    app = Flask(__name__)

    # uri     数据库+驱动://用户名:密码@主机:端口/具体哪一个库
    # app.config['SQLALCHEMY_DATABASE_URI'] = "mysql+pymysql://root:@localhost:3306/flask"
    # app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.config.from_object(envs.get(env))
    init_ext(app)
    init_view(app=app)
    return app
